<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>连板天梯</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">						
			#towriter{
				margin-top:-15px;
				border: 3px solid #555555;				
			}			
			.fixedBox{					
				white-space: nowrap;
			}
			.fixedBox::-webkit-scrollbar {
				width: 12px;     
				height: 12px;				
			}			
			p {margin-top:0px;margin-bottom:5px}				
			
			table{
				width:60px; 
				border-collapse:collapse; 
				text-align:center;				
			}
			td,th{border:1px solid #696969;}			
			th { 
				color:#E1FFFF;  <!-- 表头文字颜色 -->
			}
			td a:link{
				color:#E1FFFF;  <!-- 列表文字颜色 -->
			}		
		</style>
	</head>
	<body>		
		<div id="towriter" class="fixedBox" style="display:none;">			
			<div id="bar" style="margin-bottom:-5px"></div>
			<div id="towrites" class="fixedBox" style="position:relative;border:none;">
		</div>
		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="DatePicker/WdatePicker.js"> </script> 
		<script>				
			var g = 5;  //不要1板改为4  ,要点“清除缓存”
			var x = 10; //显示数量
			if(localStorage.getItem('lbttrq') != null) { //增加数量 重建日期缓存
				var t = localStorage.getItem('lbttrq');
				if(x > t.split(';').length - 1){										
					localStorage.removeItem('lbttrq'); 					
				}	
			}
			var bkcolor = $("body").css("backgroundColor");
			var thcolor = "";
			var tdcolor = "";
			var day = new Date();
			var dt = "";  //当日	
			var tt = "";
			var tt1 = "";
			var k = 0;				
			window.onload = function() {
				dt = day.Format("yyyy-MM-dd");				
				changeStyle();	
				getSource();								
			}
						
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					day = new Date();
					getSource();					
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}　　　
   　　　
			$(function() {
				setInterval(function() {					
				time_range("9:00","15:15")																
				},
				60000);
			})
			
			function changeStyle() {
				var obj = document.getElementById("towriter");
				obj.style.display= "block";
				obj.style.left= "0px"; 				
				obj.style.width= "100%";
				obj.style.height= "100%";
				
				var div = document.getElementById("towrites");
				div.style.left= "0px"; 				
				div.style.width= "200%";	//根据显示天数，修改百分比
				//div.style.height= "97%";
				
				for (i = 1; i < x + 1; i++){
					var obj = document.createElement("div");
					obj.id = "towrite" + (i);
					obj.className = "fixedBox";
					obj.style.position= "relative"; 
					obj.style.float= "left"; 
					obj.style.left= "0px"; 	
					obj.style.marginLeft= "5px"; 
					obj.style.width= "235px";     //板块列表宽度					
					obj.style.fontSize="12px";	
					//obj.style.border= "1px solid #fff";
					div.appendChild(obj);					
				}				
			}					
			
			function getLocalTime(nS) {			          
				return new Date(parseInt(nS) * 1000).Format("hh:mm:ss")
			}
			
			function keepTwoDecimal(num) {  
               var result = parseFloat(num);  
               if (isNaN(result)) {  
                   //alert('传递参数错误，请检查！');  
                   return false;  
               }  
               result = Math.round(num * 100) / 100;  
               return result;  
			};	
			
			function NumberTransform(num) { 
				var result = parseFloat(num);
				if (isNaN(result)) {                    
                   return false;  
               }  				
               if(Math.abs(result) > 100000000){
				result = result / 100000000;
				result = result.toFixed(2) + "亿";
			   }else if(Math.abs(result) > 10000){
			    result = result/10000;
				result = result.toFixed(0) + "万";
			   }
               return result;  
			};
			
			Date.prototype.Format = function (fmt) {
				var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
				};
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};
			
			function cDayFunc(dp) { 
				var date = dp.cal.getNewDateStr();            
				BookingRmk(date);//调用其它函数并带上参数                
			}
			
			function BookingRmk(date){         				
				tt1 = date;
				var date1 = new Date(tt1);
				var date2 = new Date(dt);
				if(date1 < date2){
					k = 1;					
				}else{
					k = 0;
					tt1 = dt;
				}				
				a = 0;  //切换日期，清零
				getSource();				
			}
			
			var pn = -1;
			function prev(){  //前一天
				pn = -1;
				var day = new Date(tt1);	
				day.setTime(day.getTime() - 24*60*60*1000);	
				tt1 = day.Format("yyyy-MM-dd");				
				BookingRmk(tt1);
			}
			
			function next(){  //后一天 				
				pn = 1;
				var day = new Date(tt1);	
				day.setTime(day.getTime() + 24*60*60*1000);	
				tt1 = day.Format("yyyy-MM-dd");				
				BookingRmk(tt1);							
			}
			
			var rqs = ""; //判断交易日用(缓存)
			var datahq = "";
			var a = 0; 
			var b = 0;
			function getSource() {	
				var div = document.getElementById("bar");
				var qh = "<a style='position:absolute; left:300px;' href='javascript:void(0)' onclick='clearstorage()'>" + "清除缓存" + "</a>";
				div.innerHTML = '<font color=#FF8C00; size="3">连板天梯<font size="1">&nbsp;&nbsp;&nbsp;&nbsp;' + qh + '</font></font><input style="width: 90px;" type="text" id="PriceDate" name="PriceDate" class="Wdate" onFocus="WdatePicker({ onpicking: cDayFunc})" />';		
				var back = '<a href="javascript:prev();"  style="padding-left:10px;font-size:16px;color:#fff;">←</a>';				
				var forward = '<a href="javascript:next();"  style="font-size:16px;color:#fff;">→</a>';
				div.innerHTML += back + forward ;
				
				//var url1 = "http://127.0.0.1:8880/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w21&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7"; 
				//var url2 = "http://127.0.0.1:8881/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&Date=" + tt1; 			

				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w21&Type=1&c=ZhiShuRanking&ZSType=7&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-d9f6-5b3d-766d-0000054d67e9"; 
				var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&st=50&a=RealRankingInfo&c=ZhiShuRanking&Index=0&apiv=w35&Type=1&ZSType=7&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-d9f6-5b3d-766d-0000054d67e9&Date=" + tt1; 	
				




				var url = url1;
				if(k == 1){
					url = url2;
				}				
				
				datahq = "";				
				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w21&Type=1&c=ZhiShuRanking&ZSType=7&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-d9f6-5b3d-766d-0000054d67e9"; 
				
				if(k == 0){				
					$.ajax({
						type: "get",
						url: url1,
						dataType: "json",
						async : false,
						cache:false,
						timeout:3000,					
						success: function(data) {					
							//alert(JSON.stringify(data))						
							//document.write(JSON.stringify(data));															
							tt1 = data.Day;							
							dt = tt1;
							day = new Date(tt1);
							rqs = tt1 + ";";  //判断交易日用										
						}
					});						
				}else{
					day = new Date(tt1);
					day.setTime(day.getTime());				
					for (i = 1; i < 100; i++){
						if(i > 1){
							day.setTime(day.getTime() + pn*24*60*60*1000);							
						}
						tt1 = day.Format("yyyy-MM-dd");						
						if(tt1 == dt){	
							k = 0;								
							getSource();
							break;
						}
						var urlt = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-d9f6-5b3d-766d-0000054d67e9&Date=" + tt1; 					
						var res1 = [];
						$.ajax({
							type: "get",
							url: urlt,
							dataType: "text",
							async : false,
							cache:false,
							timeout:3000,						
							success: function(data) {							
								if(data.indexOf("MYSQL数据库链接出错!") == -1 && data.indexOf('"list":[]') == -1 && data.indexOf('"errcode":1020') == -1){
									var arr = JSON.parse(data);
									res1 = arr.list;								
								}else{
									res1.push("");
								}														
							}
						});
						if(res1[0].length != 0){							
							break;
						}
					}
				}
				
				<!-- var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&ZSType=7&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-d9f6-5b3d-766d-0000054d67e9&Date=" + tt1; 			 -->
				<!-- var url = url1; -->
				<!-- if(k == 1){ -->
					<!-- url = url2; -->
				<!-- } -->
				<!-- var res = []; -->
				<!-- $.ajax({ -->
					<!-- type: "get", -->
					<!-- url: url, -->
					<!-- dataType: "json", -->
					<!-- async : false, -->
					<!-- cache:false, -->
					<!-- timeout:3000,					 -->
					<!-- success: function(data) {					 -->
						<!-- //alert(JSON.stringify(data))						 -->
						<!-- //document.write(JSON.stringify(data));															 -->
						<!-- for (i = 0; i < data.list.length; i++){ -->
							<!-- res.push({"code":data.list[i][0],"name":data.list[i][1],"qd":data.list[i][2],"zf":data.list[i][3]});							 -->
						<!-- }											 -->
					<!-- } -->
				<!-- });	 -->
			
				var div = document.getElementById('towrite1');	
				div.innerHTML = "<span style='color:#FFFF00'>" + tt1 + "</span>";
				document.getElementById("PriceDate").value = tt1;	
				
				if(k == 0 || localStorage.getItem('lbtta' + tt1) == null){
					for (i = 0; i < g; i++){
						getdata(5 - i);					
					}
				}else{
					datahq = localStorage.getItem('lbtta' + tt1);
				}				
				datahq = datahq.replace(/\}\]\[\{/g,"},{");
				//document.write(datahq);
				if(datahq != ""){
					Ctable(datahq,"towrite1");					
					var table = div.getElementsByTagName("table")[0];
					makeSortable(table);
				}
				
				thcolor = $("th").css("color");				
				tdcolor = $("td a:first").css("color");		
			
				for (i = 1; i < x + 1; i++){  
					$("#towrite" + i).scrollTop(0);  //回到顶部
				}
									
				if(k == 0){					
					if(dt == tt1 && b == 0){ //竞价后切换
						a = 0;
						b++;
					}
					a++;
					//alert(a)
					if(a == 1){  //刷新或竞价后执行一次							
						gethis(); //交易日推算
					}else{					
						rdbj();
					}
				}else{
					gethis();						
				}
			}
			
			function getdata(i) {				
				var url1 = "https://apphq.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=100&apiv=w21&Type=4&c=HomeDingPan&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-b828-cd79-9ea7-00000dcc13a8&PidType=" + i; 								
				var url2 = "https://apphis.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w26&Type=4&c=HisHomeDingPan&Index=0&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-b828-cd79-9ea7-00000dcc13a8&PidType=" + i + "&Day=" + tt;
				
				var url = url1;
				if(k == 1){
					url = url2;
				}
				var res = [];
				$.ajax({
					type: "get",
					url: url,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));								
						if(data.info[0].length > 0){					
							for (var j = 0; j < data.info[0].length; j++){
								var lbs = data.info[0][j][18];
								if(i < 5){
									lbs = i + "连板";
								}
								if(i == 1){
									lbs = "1板";
								}
								res.push({"code":data.info[0][j][0],"name":data.info[0][j][1],"fde":NumberTransform(data.info[0][j][6]),"lb":lbs,"ztsj":data.info[0][j][4],"ztyy":data.info[0][j][5]});							
							}
						}
					}
				});					
				if(res.length > 0){
					datahq += JSON.stringify(res);					
				}else{
					datahq += "";
				}										
			}
			
			function gethis() {			
				if(localStorage.getItem('lbttrq') != null) {  //判断有无缓存日期
					var t = localStorage.getItem('lbttrq'); //取缓存日期					
					if(t.split(";")[0] != tt1){  //如果缓存首日不等于最后交易日，重新计算
						for (j = 1; j < x; j++){															
							gethisdata();
							var div = document.getElementById("towrite" + (j + 1));	
							div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";	
							if(datahis != ""){
								Ctable(datahis,"towrite" + (j + 1));
								var table = div.getElementsByTagName("table")[0];
								makeSortable(table);
							}
						}
						if(k == 0){					
							localStorage.setItem('lbttrq', rqs);  //交易日期写入缓存
						}
					}else{  //否则取缓存数据
						for (i = 1; i < x; i++){
							var div = document.getElementById("towrite" + (i + 1));
							tt = t.split(";")[i];
							div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";
							datahis = localStorage.getItem('lbtta' + tt);
							if(datahis != ""){
								Ctable(datahis,"towrite" + (i + 1));
								var table = div.getElementsByTagName("table")[0];
								makeSortable(table);
							}
						}				
					}				
				}else{   //首次
					for (j = 1; j < x; j++){										
						gethisdata();
						var div = document.getElementById("towrite" + (j + 1));	
						div.innerHTML = "<span style='color:#FFFF00'>" + tt + "</span>";	
						if(datahis != ""){
							Ctable(datahis,"towrite" + (j + 1));
							var table = div.getElementsByTagName("table")[0];
							makeSortable(table);
						}
					}					
					localStorage.setItem('lbttrq', rqs);  //交易日期写入缓存
				}	
				rdbj();	
			}
			
				
			var datahis = "";	
			function gethisdata() {				
				datahis = "";				
				day.setTime(day.getTime());				
				for (i = 1; i < 100; i++){	//节假日																										
					day.setTime(day.getTime() - 24*60*60*1000);
					tt = day.Format("yyyy-MM-dd");
					//alert(tt);
					//var url = "http://127.0.0.1:8881/w1/api/index.php?Order=1&a=RealRankingInfo&st=30&apiv=w26&Type=1&c=ZhiShuRanking&PhoneOSNew=1&ZSType=7&Date=" + tt; 	
					
					var url = "https://apphis.longhuvip.com/w1/api/index.php?Order=1&st=50&a=RealRankingInfo&c=ZhiShuRanking&Index=0&apiv=w35&Type=1&ZSType=7&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-3e14-3180-4b1a-000004eb8671&Date=" + tt; 		
					
					var res = [];
					$.ajax({
						type: "get",
						url: url,
						dataType: "text",
						async : false,
						cache:false,
						timeout:3000,						
						success: function(data) {							
							if(data.indexOf("MYSQL数据库链接出错!") == -1 && data.indexOf('"list":[]') == -1 && data.indexOf('"errcode":1020') == -1){								
								res = JSON.parse(data);
							}														
						}
					});
					if(res.length != 0){	
						rqs += tt + ";"
						if(localStorage.getItem('lbtta' + tt) != null) {   //判断有无缓存数据														
							datahis = localStorage.getItem('lbtta' + tt);    //取缓存数据							
						}else{														
							for (i = 0; i < g; i++){
								writeSource2(5 - i);					
							}							
							datahis = datahis.replace(/\}\]\[\{/g,"},{");							
							localStorage.setItem('lbtta' + tt, datahis);  //历史单日数据写入缓存
						}				
						break;
					}					
				}				
			}
			
			function writeSource2(i) {
				//var url = "http://127.0.0.1:8881/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w26&Type=4&c=HisHomeDingPan&Index=0&PidType=" + i + "&Day=" + tt;	
				var url = "https://apphis.longhuvip.com/w1/api/index.php?Order=0&a=DailyLimitPerformance&st=1000&apiv=w26&Type=4&c=HisHomeDingPan&Index=0&VerSion=5.13.0.2&PhoneOSNew=1&DeviceID=ffffffff-b828-cd79-9ea7-00000dcc13a8&PidType=" + i + "&Day=" + tt;
							
				var res = [];
				$.ajax({
					type: "get",
					url: url,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));								
						if(data.info[0].length > 0){					
							for (var j = 0; j < data.info[0].length; j++){
								var lbs = data.info[0][j][18];
								if(i < 5){
									lbs = i + "连板";
								}
								if(i == 1){
									lbs = "1板";
								}
								res.push({"code":data.info[0][j][0],"name":data.info[0][j][1],"fde":NumberTransform(data.info[0][j][6]),"lb":lbs,"ztsj":data.info[0][j][4],"ztyy":data.info[0][j][5]});							
							}
						}
					}
				});					
				if(res.length > 0){
					datahis += JSON.stringify(res);					
				}else{
					datahis += "";
				}						
			}
			
			function Ctable(ss,id){
			//alert(ss)
				var json = JSON.parse(ss);				
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
																				
				for(var key in json[0]){  //表头
					key = key.replace('code','代码').replace('name','名称').replace('fde','封单额').replace('lb','连板').replace('ztyy','涨停原因').replace('ztsj','涨停时间');					
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);	
					//th.style.color = "#E1FFFF";
					if(key == "连板"){												
						th.style.color = "#FFA500";							
					}
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				//遍历json
				for(var i = 0; i < json.length; i++){					
					var tr=document.createElement("tr");						
					var p = 1;
					var dm = "";
					var mc = "";
					for(var key in json[i]){ //行元素遍历						
						var td=document.createElement("td");							
						
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							tr.id = dm + id;
						}else if(p == 2){  //名称列
							mc = rc;								
						}	
						td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' style='float:left;'  onclick='changeCss(this,\"" + dm + id + "\",\"" + id + "\")'>" + rc + "</a>";																										
						//td.getElementsByTagName("a")[0].style.color = "#E1FFFF";
						if(p == 4){														
							td.getElementsByTagName("a")[0].style.color = "#FFA500";
						}					
						tr.appendChild(td);							
						p++;
					}																																	
					tbody.appendChild(tr);						
						
				}
				var div = document.getElementById(id);					
				div.appendChild(table);
				table.id = id;
				changeTable(table,"0#4");		//隐藏某列	
				hover();				
			}
			
			//隐藏某列				
            function changeTable(table,ss) {	
				var trs = table.rows;
				ss = ss + '#';
				var aa = ss.split('#');
				for (var j = 0; j < aa.length; j++) {
					if(aa[j] != ""){
						for (var i = 0, len = trs.length; i < len; i++) {					
							var p = aa[j];
							var cell = trs[i].cells[p]; 
							cell.style.display = 'none';
						}
					}
				}					
			}
			
			//方式1		
			var pid = "";
			function changeCss1(obj,hid,id){						
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}	
				
				//5组选中行id集合
				if(pid.indexOf(id) > -1){				
					var aa = "";				
					var ss = pid.split(";");
					for(i = 0; i < ss.length-1; i++){
						if(ss[i].indexOf(id) > -1){						
							aa += hid + ";";
						}else{
							aa += ss[i] + ";";
						}				
					}
					pid = aa;
				}else{
					pid += hid + ";";
				}
				
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = "#483D8B";						
			}
			
			//方式2：相同行高亮
			function changeCss(obj,hid,id){				
				var tlist = document.getElementById("towriter").getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}	
								
				pid = "";				
				var dm = hid.split("towrite")[0];				
				for(var i = 0; i < tlist.length; i++){
					var a = tlist[i].id;					
					if(tlist[i].id.split("towrite")[0] == dm){						
						var ids = tlist[i].id.replace(dm,"");						
						if(ids != id){  //被点击行不滚动
							$("#" + ids).scrollTop (0);												
							var y = getTop(tlist[i]);  //纵坐标
							var div = document.getElementById(ids);						
							if(y > div.clientHeight){						
								$("#" + ids).scrollTop (y - 100);  //控制滚动条
							}
						}
						tlist[i].style.backgroundColor = "#483D8B";						
						pid += tlist[i].id + ";";
					}					
				}					
			}
			
			//获取元素的纵坐标 
			function getTop(e){ 
				var offset=e.offsetTop; 
				if(e.offsetParent!=null) offset+=getTop(e.offsetParent);				
				return offset; 
			} 			

			function hover(){  //鼠标经过			
				var rows = document.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头							
							if(pid.indexOf(this.id) == -1){  //过滤选中行
								this.style.background = bkcolor;
							}else{
								this.style.background="#483D8B";
							}
						}						
					}					
				}
			}
			
			function clearstorage(){									
				if(localStorage.getItem('lbttrq') != null){						
					localStorage.removeItem('lbttrq'); //清除缓存localStorage
				}
				
				var n = 1;
				while (n > 0)
				{	
					var p = 1;				
					var q = p;
					for (var i = 0; i < localStorage.length; i++) { 
						var key = localStorage.key(i);		 				
						if(key.indexOf('lbtta') > -1){
							//alert(key)		
							localStorage.removeItem(key);	
							p++;
						}	
					}
					n = p - q;
					//alert(n);
				}
				alert('清除完成');
			}
						
			function makeSortable(table) {			
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){
													
							showCol(table,n);		//高亮
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("连板") != -1 || headtxt.indexOf("涨停原因") != -1){
									val1 = val1;
									val2 = val2;
								}else{											
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
							});
							if(flag){
								rows.reverse();
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
						}
					}(i));
				}
			}
			
			function showCol(table,iCol){			
				var oTable = table;
				var id = oTable.id;
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = thcolor;
						oTable.rows[i].cells[3].style.color = "#FFA500";					
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}
				
				var otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = tdcolor;
					if(otagsA[i].id == 4){
						otagsA[i].style.color = "#FFA500";
					}						
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}				
			}
			
			function rdbj() {		//高亮标记	
				//alert(1)
				var dms = "";
				var tlist = document.getElementById("towrites").getElementsByTagName("tr");
				for(var i = 1; i < tlist.length; i++){
					if(tlist[i].id != ""){
						dms += tlist[i].id.split('towrite')[0] + ",";
					}
				}
				
				<!-- 全部标记 -->
				for(var i = 1; i < tlist.length; i++){
					var dm = tlist[i].id.split('towrite')[0];
					if(dms.indexOf(dm) > -1 && dm != ""){
						var ss = dms.split(dm);	
						if(ss.length - 1 >= 5){																									
							tlist[i].style.border = "2px solid #FF0000";							
							//tlist[i].getElementsByTagName("a")[1].style.color = "#FF0000";
						}else if(ss.length - 1 == 4){							
							tlist[i].style.border = "2px solid #FF00FF";
							//tlist[i].getElementsByTagName("a")[1].style.color = "#FF00FF";
						}
					}					
				}
				
				<!-- 以当日数据为基准标注 -->
				<!-- var div1 = document.getElementById('towrite1'); -->
				<!-- var rows1 = div1.getElementsByTagName('tr'); -->
				<!-- for(var i = 1; i < rows1.length; i++){ -->
					<!-- var dm = rows1[i].id.split('towrite')[0];					 -->
					<!-- var ss = dms.split(dm);					 -->
					<!-- if(ss.length - 1 > 1){ -->
						<!-- var rows = document.getElementById("towrites").getElementsByTagName('tr'); -->
						<!-- for(var j = 0; j < rows.length; j++){ -->
							<!-- var dmh = rows[j].id.split('towrite')[0]; -->
							<!-- if(dmh == dm){								 -->
								<!-- if(ss.length - 1 >= 5){																										 -->
									<!-- rows[j].style.border = "2px solid #FF0000"; -->
								<!-- }else if(ss.length - 1 == 4){									 -->
									<!-- rows[j].style.border = "2px solid #FF00FF"; -->
								<!-- }								 -->
							<!-- } -->
						<!-- } -->
					<!-- }					 -->
				<!-- } -->
			}
		</script>
		
	</body>
</html>